﻿using BS.Infra;
using BS.Read.Api.Handler.RBAC;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace BS.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RBACController : ControllerBase
    {
        private readonly IMediator _mediator;

        public RBACController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 显示用户和角色
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> ShowUserAndRole([FromQuery]GetUserWithRoleRequestDTO parm)
        {
            return await _mediator.Send(parm);
        }
        /// <summary>
        /// 树形角色权限
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> TreePermissions([FromQuery]GetPermissionsRequestDTO parm)
        {
            return await _mediator.Send(parm);
        }
    }
}
